import axios from 'axios';

// axios.defaults.baseURL = process.env.VUE_APP_BASE_URL;
console.log("....request.js->vue_app_base_url:" + process.env.VUE_APP_BASE_URL);

const service = axios.create({
    headers: {
        'Content-Type': 'application/json'
    },
    /*transformRequest: [function(data) {
        console.log("---before param:" + data);
        data = JSON.stringify(data);
        console.log("---after param:" + data);
        return data
    }],*/
    // process.env.NODE_ENV === 'development' 来判断是否开发环境
    // easy-mock服务挂了，暂时不使用了
    baseURL: process.env.VUE_APP_BASE_URL/*,
    timeout: 5000*/
});

service.interceptors.request.use(
    config => {
        return config;
    },
    error => {
        console.log(error);
        return Promise.reject();
    }
);
/*
service.interceptors.response.use(
    response => {
        if (response.status === 200) {
            return response.data;
        } else {
            Promise.reject();
        }
    },
    error => {
        console.log(error);
        return Promise.reject();
    }
);*/

export default service;
